<extend name="Public/base" />
<block name="main">
    <script type="text/javascript" src="__PUBLIC__/dataTable/jquery.dataTables.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/css/dataTable.css">
    <fieldset class="layui-elem-field">
        <legend>短信管理 - 发送记录管理</legend>
        <div class="layui-field-box">
            <form class="layui-form" id="form-admin-add" action="{:U("send")}"  method="post" >
                <div class="layui-form-item">
                    所属商户：
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="company_name" placeholder="请输入关键词" class="layui-input" value="{$info['company_name']}">
                        </div>
                    </div>
                    号码：
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="mobile" placeholder="请输入关键词" class="layui-input" value="{$info['mobile']}">
                        </div>
                    </div>
                    内容：
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="content" placeholder="请输入关键词" class="layui-input"  value="{$info['content']}">
                        </div>
                    </div>
                    发送时间
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="startTime"  lay-verify="required"  class="layui-input" style="width:100px;" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD'})"  value="{$info['startTime']}">
                        </div>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="endTime"  lay-verify="required"  class="layui-input" style="width:100px;" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD'})"  value="{$info['endTime']}">
                        </div>
                    </div>
                    类型：
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width: 100px;">
                            <select name="type">
                                <option value=""  selected>请选择类型</option>
                                <option value="1"  <if condition=" $info['type'] eq 1 "> selected </if>>定时</option>
                                <option value="2"  <if condition=" $info['type'] eq 2 "> selected </if>>即时</option>
                            </select>
                        </div>
                    </div>
                    状态：
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width: 100px;">
                            <select name="status">
                                <option value=""  selected>请选择状态</option>
                                <option value="1" <if condition=" $info['status'] eq 1 "> selected </if>>发送成功</option>
                                <option value="2" <if condition=" $info['status'] eq 2 "> selected </if>>发送失败</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <!-- <span class="layui-btn sub">查询</span> -->
                        <input type="submit" value="查询" name="name" class="layui-btn"/>
                    </div>
                </div>
            </form>
            <table class="layui-table" id="list-admin" lay-even>
                <thead>
                <tr>
                    <th>#</th>
                    <th>所属商户</th>
                    <th>号码</th>
                    <th>内容</th>
                    <th>接收时间</th>
                    <th>发送时间</th>
                    <th>类型</th>
                    <th>状态</th>
                    <th>上次操作人</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <volist name="data" id="vo">
                    <tr>
                        <td>{$vo['id']}</td>
                        <td>{$vo['company_name']}</td>
                        <td>{$vo['mobile']}</td>
                        <td>{$vo['content']}</td>
                        <td><?php echo date("Y-m-d H:i:s",$vo['receive_time']) ?> </td>
                        <td><?php echo date("Y-m-d H:i:s",$vo['send_time']) ?> </td>
                        <td><if condition="$vo['type'] eq 1">定时<else />即时</if></td>
                        <td><if condition="$vo['status'] eq 0">未处理<elseif condition="$vo['status'] eq 1" />成功<else/>失败</if></td>
                        <td align="center">{$vo['adminName']}</td>
                        <td>
                            <span class="layui-btn layui-btn-danger del" data-id="{$vo['id']}" data-info="你确定删除当前记录吗？" data-url="{:U('delSend')}">删除</span>
                            <if condition="$vo['status'] eq 2">
                                <span class="layui-btn layui-btn-danger confirm" data-id="{$vo['id']}" data-info="你确定立即手动发送吗？" data-url="{:U('recordSend')}">立即手动发送</span>
                            </if>
                        </td>
                    </tr>
                </volist>
                </tbody>
            </table>

        </div>

    </fieldset>
</block>
<block name="myScript">
    <script type="text/javascript" src="__PUBLIC__/layui/lay/modules/laydate.js"></script>
    <script>
        layui.use(['layer', 'form'], function() {
            $('.confirm').on('click', function () {
                var ownObj = $(this);
                layer.confirm(ownObj.attr('data-info'), {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    $.ajax({
                        type: "POST",
                        url: ownObj.attr('data-url'),
                        data: {id:ownObj.attr('data-id')},
                        success: function(msg){
                            if( msg.code == 1 ){
                                location.reload();
                            }else{
                                layer.msg(msg.msg, {
                                    icon: 5,
                                    shade: [0.6, '#393D49'],
                                    time:1500
                                });
                            }
                        }
                    });
                });
            });

            $('.del').on('click', function () {
                var ownObj = $(this);
                layer.confirm(ownObj.attr('data-info'), {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    $.ajax({
                        type: "POST",
                        url: ownObj.attr('data-url'),
                        data: {id:ownObj.attr('data-id')},
                        success: function(msg){
                            if( msg.code == 1 ){
                                location.reload();
                            }else{
                                layer.msg(msg.msg, {
                                    icon: 5,
                                    shade: [0.6, '#393D49'],
                                    time:1500
                                });
                            }
                        }
                    });
                });
            });

            var myTable = myFun();
            $('.sub').on("click", function(){
                myTable.destroy();
                myTable = myFun('&'+ $('#form-admin-add').serialize());
            });
        });
    </script>
</block>